<?php

//UMA new
use Illuminate\Database\Seeder;
use App\Models\InputGroup;

class ItemGroupSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $item_groups = [
            [
                'input_group' => '基本情報',
                'identifier' => 'basic',
                
                'items' => [
                    [
                        'item_name' => '性別',
                        'input_name' => 'sex',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '男性',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '女性',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '無回答',
                                'rate' => 1,
                            ]
                        ]
                    ],
                    [
                        'item_name' => '生まれ年',
                        'input_name' => 'year_of_birth',
                        'input_type' => 'text',
                        'options' => [
                            [
                                'item_name' => '30歳未満',
                                'rate' => 1,
                                'option_value' => '1',
                            ],
                            [
                                'item_name' => '40歳未満',
                                'rate' => 1,
                                'option_value' => '30',
                            ],
                            [
                                'item_name' => '50歳未満',
                                'rate' => 1,
                                'option_value' => '40',
                            ],
                            [
                                'item_name' => '60歳未満',
                                'rate' => 0.9,
                                'option_value' => '50',
                            ],
                            [
                                'item_name' => '70歳未満',
                                'rate' => 0.7,
                                'option_value' => '60'
                            ],
                            [
                                'item_name' => '70歳以上',
                                'rate' => 0.5,
                                'option_value' => '70',
                            ],
                        ]
                    ],
                    

                    [
                        'item_name' => '国籍',
                        'input_name' => 'nation',
                        'input_type' => 'radio',
                        'options' => [
                            [
                                'item_name' => '日本国籍・外国籍（永住権有り）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '外国籍（永住権無し）',
                                'rate' => 0.5,
                            ],
                        ]
                    ],
                    
                    [
                        'item_name' => '配偶者',
                        'input_name' => 'marriage',
                        'input_type' => 'radio',
                        'options' => [
                            [
                                'item_name' => '有',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '無',
                                'rate' => 0.8,
                            ]
                        ]
                    ],

                    [
                        'item_name' => '家族構成',
                        'input_name' => 'family_structure',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '一人暮らし',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '配偶者と同居 ',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '配偶者・子どもと同居',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '子どもと同居',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '親・配偶者と同居',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '親・配偶者・子どもと同居',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '親・子どもと同居',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'その他',
                                'rate' => 1,
                            ]
                        ]
                    ],

                    [
                        'item_name' => '同居人数',
                        'input_name' => 'family_members_quantity',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '1人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '2人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '3人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '4人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '5人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '6人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '7人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '8人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '9人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '10人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'それ以上',
                                'rate' => 1,
                            ],
                        ]
                    ],


                    [
                        'item_name' => '扶養',
                        'input_name' => 'raise',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '0人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '1人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '2人',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '3人',
                                'rate' => 0.95,
                            ],
                            [
                                'item_name' => '4人以上',
                                'rate' => 0.9,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '運転免許証番号',
                        'input_name' => 'driver_lesson_number',
                        'input_type' => 'text',
                    ]
                ],
            ],
            [
                'input_group' => 'お仕事について',
                'identifier' => 'work',
                'items' => [
                    [
                        'item_name' => '勤務先/学校名',
                        'input_name' => 'working_school_name',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校名カナ',
                        'input_name' => 'working_school_name_kana',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校郵便番号',
                        'input_name' => 'working_school_zip',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校住所（都道府県)',
                        'input_name'=> 'working_school_pref',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校住所（都道府県市区町村）',
                        'input_name' => 'working_school_city',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校住所（番地）',
                        'input_name' => 'working_school_town',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校住所（建物名・部屋番号）',
                        'input_name' => 'working_school_building',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先/学校電話番号',
                        'input_name' => 'working_school_tel',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先雇用形態',
                        'input_name' => 'hirement',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '自営業（2年未満)',
                                'rate' => 0.6,
                            ],
                            [
                                'item_name' => '自営業（2年以上)',
                                'rate' => 0.8,
                            ],
                            [
                                'item_name' => '公務員',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '農林漁業',
                                'rate' => 0.8,
                            ],
                            [
                                'item_name' => '医師・弁護士・会計士・その他士業',
                                'rate' => 1,
                            ],

                            [
                                'item_name' => '会社員',
                                'rate' => 0.95,
                            ],
                            

                            [
                                'item_name' => '会社代表',
                                'rate' => 0.85,
                            ],
                            [
                                'item_name' => '会社役員',
                                'rate' => 0.9,
                            ],
                            [
                                'item_name' => '短期社員',
                                'rate' => 0.9,
                            ],
                            [
                                'item_name' => '派遣社員',
                                'rate' => 0.8,
                            ],
                            [
                                'item_name' => 'パート・アルバイト',
                                'rate' => 0.75,
                            ],
                            [
                                'item_name' => '年金のみ',
                                'rate' => 0.8,
                            ]
                        ]
                    ],
                    [
                        'item_name' => '勤務先職種',
                        'input_name' => 'work_type',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '農林水産業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '建設業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '製造業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '電気ガス水道',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '情報通信業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '運輸・倉庫',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '放送出版・情報',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '卸売・小売業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '飲食・宿泊',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '金融・保険',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '教育・医療・福祉',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '不動産業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'サービス業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '公務',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'その他',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '勤務先担当業務',
                        'input_name' => 'work_responsibility',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '会社経営者',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '企画・マーケティング・事務',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '営業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'ITエンジニア（システム開発・SE・インフラ）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'クリエイティブ（メディア・アパレル・デザイン）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'コンサルタント',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'エンジニア（機械・電気・電子・半導体・制御）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '素材・化学・食品・医薬品技術職',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '製造職（工場内ライン作業）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '技能職（機械オペレーター）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '工場倉庫内作業者',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '建築・土木現場作業員',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '運転手（トラック・タクシー・バス・送迎）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '農林水産従事',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '医師・弁護士・会計士',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '税理士・その他士業',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '教員',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '保安職（警官・自衛官）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '医療・福祉・介護',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '保育・教育',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '店員・接客（サービス・販売・外食）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'その他業',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '勤務先所属部課',
                        'input_name' => 'work_department',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '勤務先上場区分',
                        'input_name' => 'work_place_type',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '個人経営',
                                'rate' => 0.95,
                            ],
                            [
                                'item_name' => '非上場',
                                'rate' => 0.95,
                            ],
                            [
                                'item_name' => '上場（東証一部）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '上場（その他市場）',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '官公庁',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'その他',
                                'rate' => 1,
                            ],

                        ],
                    ],

                    // [
                    //     'item_name' => '勤務先',
                    //     'input_name' => 'working_place',
                    //     'input_type' => 'select',
                    //     'options' => [
                    //         [
                    //             'item_name' => '個人経営',
                    //             'rate' => 0.95,
                    //         ],
                    //         [
                    //             'item_name' => '非上場',
                    //             'rate' => 0.95,
                    //         ],
                    //         [
                    //             'item_name' => '上場',
                    //             'rate' => 1,
                    //         ],
                    //         [
                    //             'item_name' => '官公庁',
                    //             'rate' => 1,
                    //         ],
                    //         [
                    //             'item_name' => 'その他',
                    //             'rate' => 1,
                    //         ],
                    //     ]
                    // ],
                    // [
                    //     'item_name' => '勤続年数',
                    //     'input_name' => 'working_years',
                    //     'input_type' => 'select',
                    //     'options' => [
                    //         [
                    //             'item_name' => '1年未満',
                    //             'rate' => 0.8,
                    //         ],
                    //         [
                    //             'item_name' => '1年以上2年未満',
                    //             'rate' => 0.9,
                    //         ],
                    //         [
                    //             'item_name' => '2年以上',
                    //             'rate' => 1,
                    //         ]
                    //     ]
                    // ],
                    [
                        'item_name' => '勤務先資本金',
                        'input_name' => 'employment_capital',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '1000万未満',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '1000万以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '5000万以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '1億円以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '5億円以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '公務員団体職員等',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '自営業',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '勤務先の従業員数',
                        'input_name' => 'employee_quantity',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '10名未満',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '20名以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '50名以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '100名以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '300名以上',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '1000名以上',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '勤務先入社年月',
                        'input_name' => 'employment_start_date',
                        'input_type' => 'text',
                        'options' => [
                            [
                                'item_name' => '1年未満',
                                'rate' => 0.8,
                                'option_value' => '0',
                            ],
                            [
                                'item_name' => '1年以上2年未満',
                                'rate' => 0.9,
                                'option_value' => '1',
                            ],
                            [
                                'item_name' => '2年以上',
                                'rate' => 1,
                                'option_value' => '2',
                            ]
                        ],
                    ],
                    [
                        'item_name' => '年収',
                        'input_name' => 'yearly_income',
                        'input_type' => 'text',
                        'options' => [
                            [
                                'item_name' => '0~199',
                                'rate' => 0.7,
                                'option_value' => '1',
                            ],
                            [
                                'item_name' => '200~299',
                                'rate' => 0.8,
                                'option_value' => '200',
                            ],
                            [
                                'item_name' => '300~399',
                                'rate' => 0.9,
                                'option_value' => '300',
                            ],
                            [
                                'item_name' => '400~499',
                                'rate' => 0.95,
                                'option_value' => '400',
                            ],
                            [
                                'item_name' => '500~599',
                                'rate' => 0.95,
                                'option_value' => '500',
                            ],
                            [
                                'item_name' => '600~699',
                                'rate' => 1,
                                'option_value' => '600'
                            ],
                            [
                                'item_name' => '700~799',
                                'rate' => 1,
                                'option_value' => '700',
                            ],
                            [
                                'item_name' => '800~899',
                                'rate' => 1,
                                'option_value' => '800',
                            ],
                            [
                                'item_name' => '900~999',
                                'rate' => 1,
                                'option_value' => '900',
                            ],
                            [
                                'item_name' => '1000~',
                                'rate' => 1,
                                'option_value' => '1000',
                            ]
                        ]
                    ],
                    [
                        'item_name' => '給与形態',
                        'input_name' => 'salary_type',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '固定給',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '歩合給',
                                'rate' => 0.8,
                            ],
                            [
                                'item_name' => 'その他',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '健康保険の種類',
                        'input_name' => 'insurance',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '社会保険',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '国民健康保険',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '共済保険',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '組合保険',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '船員保険',
                                'rate' => 1,
                            ],
                        ]
                    ],
                ]
            ],
            [
                'input_group' => 'お住まいについて',
                'identifier' => 'residence',
                'items' => [
                    [
                        'item_name' => '現在の住まい',
                        'input_name' => 'residence_place',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '本人持ち家',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '家族持ち家',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '公団・公営住宅',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '賃貸住宅',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '一戸建て借家',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'アパート',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '寮',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '社宅',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => 'その他',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '家賃',
                        'input_name' => 'rent',
                        'input_type' => 'text',
                    ]
                ]
            ],
            
            [
                'input_group' => 'その他',
                'identifier' => 'other',
                'items' => [
                    [
                        'item_name' => '口座残高',
                        'input_name' => 'balance',
                        'input_type' => 'text',
                        'options' => [
                            [
                                'item_name' => '0~99',
                                'rate' => 0.9,
                                'option_value' => '0',
                            ],
                            [
                                'item_name' => '100~299',
                                'rate' => 0.95,
                                'option_value' => '100'
                            ],
                            [
                                'item_name' => '300~999',
                                'rate' => 1,
                                'option_value' => '300',
                            ],
                            [
                                'item_name' => '1000~',
                                'rate' => 1,
                                'option_value' => '1000',
                            ],
                        ],
                    ],
                    [
                        'item_name' => 'その他借り入れの有無',
                        'input_name' => 'has_borrowing',
                        'input_type' => 'radio',
                        'options' => [
                            [
                                'item_name' => '有',
                                'rate' => 1,
                            ],
                            [
                                'item_name' => '無',
                                'rate' => 1,
                            ],
                        ]
                    ],
                    [
                        'item_name' => '既存の借入（オートローン）', // 汽车贷款
                        'input_name' => 'auto_loan',
                        'input_type' => 'select',
                        'options' => [
                            
                            [
                                'item_name' => '有り（延滞実績無し）',
                                'rate' => 0.95,
                            ],
                            [
                                'item_name' => '有り（延滞実績有り）',
                                'rate' => 0.7,
                            ],
                            [
                                'item_name' => '無',
                                'rate' => 1,
                            ],
                        ],
                    ],
                    [
                        'item_name' => '毎月の返済額（オートローン）',
                        'input_name' => 'monthly_autoloan_repayment',
                        'input_type' => 'text',
                    ],

                    [
                        'item_name' => '既存の借入（キャッシング・カードローン）', // 现有借款（现金卡借款）
                        'input_name' => 'cash_loan',
                        'input_type' => 'select',
                        'options' => [
                            
                            [
                                'item_name' => '有り（延滞実績無し）',
                                'rate' => 0.85,
                            ],
                            [
                                'item_name' => '有り（延滞実績有り）',
                                'rate' => 0.7,
                            ],
                            [
                                'item_name' => '無',
                                'rate' => 1,
                            ],
                        ],
                    ],
                    [
                        'item_name' => '毎月の返済額（キャッシング・カードローン）',
                        'input_name' => 'monthly_cashloan_repayment',
                        'input_type' => 'text',
                    ],
                    [
                        'item_name' => '既存の借入（その他ローン)', //现有借款（其他贷款）
                        'input_name' => 'other_loan',
                        'input_type' => 'select',
                        'options' => [
                            [
                                'item_name' => '有り（延滞実績無し）',
                                'rate' => 1,
                            
                            ],
                            [
                                'item_name' => '有り（延滞実績有り）',
                                'rate' => 1,
                            ],

                            [
                                'item_name' => '無',
                                'rate' => 1,
                            ],
                        ],
                    ],
                    [
                        'item_name' => '毎月の返済額（その他ローン）',
                        'input_name' => 'monthly_otherloan_repayment',
                        'input_type' => 'text',
                    ],
                ]
            ]
        ];

        foreach ($item_groups as $group) {
            //create group
            $groupObj = InputGroup::create(['input_group' => $group['input_group']
            , 'identifier' => $group['identifier']]);
            if (!empty($group['items'])) {
                foreach ($group['items'] as  $item) {
                    $itemData['input_item'] = $item['item_name'];
                    $itemData['identifier'] = $item['input_name'];
                    //create item
                    $itemObj = $groupObj->items()->create($itemData);
                    if (!empty($item['options'])) {
                        foreach ($item['options'] as $k => $option) {
                            $optionRow['option_name'] = $option['item_name'];
                            $optionRow['option'] = isset($option['option_value'])? $option['option_value'] : $k +1;
                            $optionRow['rate'] = $option['rate'];
                            //create option
                            $itemObj->options()->create($optionRow);
                        }
                    }
                }
            }
        }
    }
}
